package com.smforj.ssm.frame.core.web.domain;

import java.io.Serializable;

/****
 * Ajax处理结果对象
 * 
 * @author Haijun Gao 
 * @date 2016-12-31 下午2:52:19
 * @param <T>
 * @desp http://www.cnblogs.com/saga5998/
 * @email 573107773@qq.com
 */
public class DataResult<T> implements Serializable {
	/**
	 * @fields serialVersionUID 
	 */
	private static final long serialVersionUID = 5905715228490291386L;
	/**
	 * @fields status  状态信息，正确返回OK，否则返回 ERROR，如果返回ERROR则需要填写Message信息
	 */
	private DataStatus status;
	/**
	 * @fields record 消息对象
	 */
	private String message;
	
	private T data;

	public DataResult() {
		super();
	}

	/**
	 * @description 
	 * @param status 状态
	 * @param message 消息
	 */
	public DataResult(DataStatus status, String message) {
		this.status = status;
		this.message = message;
	}
	
	/**
	 * @description 
	 * @param status 状态
	 * @param message 消息
	 * @param data 数据
	 */
	public DataResult(DataStatus status, String message,T data) {
		this.status = status;
		this.message = message;
		this.data = data;
	}

	/**
	 * 结果类型信息
	 * @author ghj
	 * @date 2014年3月7日下午4:20:23
	 */
	public enum DataStatus {
		OK, ERROR
	}

	/**
	 * 添加成功结果信息
	 * @param record
	 */
	public void addOK(String message,T data) {
		this.message = message;
		this.status = DataStatus.OK;
		this.data = data;
	}

	/**
	 * 添加错误消息
	 * @param message
	 */
	public void addError(String message) {
		this.message = message;
		this.status = DataStatus.ERROR;
	} 

	public DataStatus getStatus() {
		return status;
	}

	public void setStatus(DataStatus status) {
		this.status = status;
	}

	public Object getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

}
